package com.bishe.controller;


import com.bishe.entity.Clue;
import com.bishe.entity.query.ClueQuery;
import com.bishe.entity.response.R;
import com.bishe.service.ClueService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * (Clue)表控制层
 *
 * @author makejava
 * @since 2024-03-04 14:00:14
 */
@RestController
@RequestMapping("clue")
@Api(tags = "线索管理")
public class ClueController{
    /**
     * 服务对象
     */
    @Resource
    private ClueService clueService;


    @ApiOperation("根据id查询案件相关人员")
    @GetMapping("selectPersonnelInfo/{id}")
    public R selectPersonnelInfo(@PathVariable String id) {
        return R.ok(clueService.selectPersonnelInfo(id));
    }


    /**
     * 分页查询所有数据
     *
     * @return 所有数据
     */
    @PostMapping("page")
    public R selectAll(@RequestBody ClueQuery query) {
        return R.ok(this.clueService.getPage(query));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public R selectOne(@PathVariable Serializable id) {
        return R.ok(this.clueService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param clue 实体对象
     * @return 新增结果
     */
    @PostMapping
    public R insert(@RequestBody Clue clue) {
        return R.ok(this.clueService.save(clue));
    }

    /**
     * 修改数据
     *
     * @param clue 实体对象
     * @return 修改结果
     */
    @PutMapping
    public R update(@RequestBody Clue clue) {
        return R.ok(this.clueService.updateById(clue));
    }

    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @DeleteMapping
    public R delete(@RequestParam("idList") List<Long> idList) {
        return R.ok(this.clueService.removeByIds(idList));
    }
}

